//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.controller;

import com.example.common.Result;
import com.example.entity.Clubmember;
import com.example.service.ClubmemberService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping({"/clubmember"})
public class ClubmemberController {
    @Resource
    private ClubmemberService clubmemberService;

    public ClubmemberController() {
    }

    @GetMapping({"/selectAll"})
    public Result selectAll(Clubmember clubmember) {
        List<Clubmember> list = this.clubmemberService.selectAll(clubmember);
        return Result.success(list);
    }

    @GetMapping({"/selectById/{id}"})
    public Result selectById(@PathVariable Integer id, @PathVariable String no) {
        Clubmember clubmember = this.clubmemberService.selectById(id);
        return Result.success(clubmember);
    }
    @GetMapping("/selectBypresidentId/{presidentId}")
    public Result selectBypresidentId(@PathVariable Integer presidentId) {
        Clubmember clubmember = this.clubmemberService.selectBypresidentId(presidentId);
        return Result.success(clubmember);
    }
    @GetMapping({"/selectByOne"})
    public Result selectByOne(@RequestParam Integer id, @RequestParam(required = false) String no) {
        Clubmember clubmember = this.clubmemberService.selectById(id);
        return Result.success(clubmember);
    }

    @GetMapping({"/selectList"})
    public Result selectList(Clubmember clubmember) {
        List<Clubmember> list = this.clubmemberService.selectList(clubmember);
        return Result.success(list);
    }

    @GetMapping({"/selectPage"})
    public Result selectPage(Clubmember clubmember, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam Integer presidentId) {
        clubmember.setPresidentId(presidentId);
        PageInfo<Clubmember> pageInfo = this.clubmemberService.selectPage(clubmember, pageNum, pageSize, presidentId);
        return Result.success(pageInfo);
    }

    @PostMapping({"/add"})
    public Result add(@RequestBody Clubmember clubmember) {
        this.clubmemberService.add(clubmember);
        return Result.success();
    }

    @PutMapping({"/updateById"})
    public Result updateById(@RequestBody Clubmember clubmember) {
        this.clubmemberService.updateById(clubmember);
        return Result.success();
    }

    @DeleteMapping({"/deleteById/{id}"})
    public Result deleteById(@PathVariable Integer id) {
        this.clubmemberService.deleteById(id);
        return Result.success();
    }

    @DeleteMapping({"/deleteBatch"})
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        this.clubmemberService.deleteBatch(ids);
        return Result.success();
    }


}
